<?php
/**
 * 
 * @author szm
 *
 */
class Vocabulary_model  extends CI_Model  {
    public function __construct(){
        parent::__construct();
        $this->load->database();
    }
    public function getVocabularies($lessonIds){
        if(empty($lessonIds)){
            return false;
        }
        if(!is_array($lessonIds)){
            $lessonIds=array($lessonIds);
        }
        $lessonIds=implode(",",$lessonIds);
        $sql="select * from glossary as g
			left join expansions  as e
        	on g.expansion_id = e.expansion_id
			where e.lesson_id in ($lessonIds)";
	     try{
            $dbSource=$this->db->query($sql);
            $resultArr=$dbSource->result_array();
            return $resultArr;
	     }catch(Exception $e){
            return $sql;
         }
    }
    public function listAllVocabularys(){
        $data=array();
        $this->load->view('list_all_vocabularys');
    }
    
    public function getVocabulary(){
        $data=array();
        $this->load->view('Vocabulary');
    }
    
    public function saveVocabulary(){
        $data=array();
        redirect('/lesson/index/', 'refresh');

    }
    
    public function removeVocabulary(){
        $data=array();
        redirect('/lesson/index/', 'refresh');
    }
}

